import json

from django.http import HttpResponse
from django.shortcuts import render

# Create your views here.
from django.views.generic import View


class ReView(View):
    def get(self, request):

        a = request.GET.get('key')
        b = request.GET.get('value')
        response = HttpResponse('%s:%s' % (a, b))
        response.set_cookie(a, b, max_age=1000)
        return response

    def post(self, request):
        print(request)

        keys = request.body.decode()
        print(keys)
        a = json.loads(keys)
        new_key = a.get('key')
        values = a.get('value')
        response = HttpResponse('%s:%s' % (new_key, values))
        response.set_cookie(new_key, values, max_age=1000)
        return response
